Skip to content

BER-80: Converting MapMarkerDetailView into SwiftUI [WIP] #341

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 38 commits into
base: master
Choose a base branch
from

Conversation

Chhumbucket
Copy link
Collaborator

Screenshot 2025-03-12 at 5 33 06 PM

Converted the MapMarkerDetailView into SwiftUI.

Currently placed templates for the buttons and used static data just to represent the view.

Future updates,

I want to connect the title of the place and the description in the same place to make sure that the padding is aligned. I feel that there is redundancy in the code, I want some feedback if there is.

@Chhumbucket Chhumbucket changed the title Dylchhum/ber 80 Ber-80: Converting MapMarkerDetailView into SwiftUI Mar 13, 2025
@Chhumbucket Chhumbucket self-assigned this Mar 13, 2025
@Chhumbucket Chhumbucket changed the title Ber-80: Converting MapMarkerDetailView into SwiftUI BER-80: Converting MapMarkerDetailView into SwiftUI Mar 13, 2025
@justinwongeecs justinwongeecs self-requested a review March 14, 2025 08:11
@baeuke baeuke self-requested a review March 20, 2025 22:37
baeuke
baeuke previously requested changes Mar 25, 2025
@Chhumbucket
Copy link
Collaborator Author

Screen.Recording.2025-03-28.at.11.04.52.PM.mov

Copy link
Collaborator

@justinwongeecs justinwongeecs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolve merge conflicts and for the past comments in the conversation, please resolve them if they have been implemented.

@Chhumbucket Chhumbucket dismissed stale reviews from justinwongeecs and baeuke March 31, 2025 20:40

Fixed the conflicts

@Chhumbucket
Copy link
Collaborator Author

Chhumbucket commented Apr 5, 2025

Screenshot 2025-04-05 at 12 15 23 AM

How do we feel abt this UI? @justinwongeecs

@justinwongeecs
Copy link
Collaborator

@Chhumbucket
Much better! I think it would be great to have the same even padding on all sides? It feels that the padding of the top is different from the bottom.

Maybe choose a padding that is a bit less than the right side? It feels that there's a bit too much negative space on the right.

@baeuke
Copy link
Collaborator

baeuke commented May 3, 2025

Search is breaking in your branch:

description

searchResultsView = UIHostingController(rootView: SearchResultsView().environmentObject(searchViewModel)).view
let resultsView = SearchResultsView().environmentObject(searchViewModel)
searchResultsHostingController = UIHostingController(rootView: AnyView(resultsView))
searchResultsView = searchResultsHostingController.view
Copy link
Collaborator

@baeuke baeuke May 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Chhumbucket You didn't resolve this one. I think we had a consistent way with the hostingController;
you better make markerDetail work same way too than changing how search components are made (don't change search).
Justin did in the same way with mapUserLocationButton.

@@ -50,19 +49,18 @@ class MapViewController: UIViewController, SearchDrawerViewDelegate {
private var searchBarViewController: UIViewController!
private var searchBar: UIView!
private var searchResultsView: UIView!
private var searchResultsHostingController: UIHostingController<AnyView>!
private var searchViewModel: SearchViewModel!
Copy link
Collaborator

@baeuke baeuke May 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to store UIHostingController variables. The reason previously we added searchBarViewController (which is a hosting controller) is because we needed to add it as a child to mapViewController to share environment and focus state (which was specific to how search works and the whole setup here). in this case there is no need for that.

@@ -71,14 +69,13 @@ class MapViewController: UIViewController, SearchDrawerViewDelegate {
private let mapUserLocationViewModel = MapUserLocationButtonViewModel()
private let mapMarkersDropdownViewModel = MapMarkersDropdownViewModel()
private var mapMarkers: [[MapMarker]] = []
private var markerDetail: MapMarkerDetailView!
private var markerDetail: UIHostingController<MapMarkerDetailSwiftView>!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. You don't need markerDetail: UIHostingController<MapMarkerDetailSwiftView>!
just make markerDetail: UIView, and follow same setup process as for mapUserLocationBtn, mapMarkersDropdown, and Search components


fetchFromMapDataSource()
createMapLocationButton()
createMapMarkerDropdownButton()

self.view.addSubViews([mapView, mapUserLocationButton, mapMarkersDropdownButton, markerDetail, searchResultsView, searchBar])
self.view.addSubViews([mapView, mapUserLocationButton, mapMarkersDropdownButton, markerDetail.view, searchResultsView, searchBar])
setupSubviews()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when consistent, here you add just markerDetail, not markerDetail.view

import MapKit
import SwiftUI

// MARK: - MapMarkerDetailSwiftView
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove MARK

Comment on lines 17 to 18
var onClose: (() -> Void)?
var body: some View {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add newline between onClose and body

var marker: MapMarker?
var onClose: (() -> Void)?
var body: some View {
ZStack {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this ZStack necessary?

Comment on lines 46 to 57
let markerColor: Color = {
guard let marker else {
return .purple
}

switch marker.type {
case .known(let type):
return Color(type.color())
case .unknown:
return Color(BMColor.MapMarker.other)
}
}()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe make this is a private helper function?

Comment on lines 72 to 79
Button {
onClose?()
} label: {
Image(systemName: "xmark")
.font(.system(size: 16))
.foregroundStyle(Color.secondary)
.padding(.trailing, 4)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use trailing closure syntax:

Button(action: {
}) {
...
}

Comment on lines 91 to 107
HStack {
HStack(spacing: 8) {
Image(systemName: "clock")
.font(.system(size: 12))
.foregroundColor(.secondary)
.rotationEffect(.init(degrees: 90))
openStatusButton
}

Spacer()

locationInfoView

Spacer()

categoryView
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the outer HStack necessary? Could we put lines 100-106 within the nested HStack?


private var openStatusButton: some View {
Capsule()
.fill(marker?.isOpen ?? false ? Color.blue : Color(red: 0.4, green: 0.5, blue: 0.9))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Color.blue.blue?

Comment on lines 140 to 150
Group {
if let marker, case .known(let type) = marker.type, type == .cafe, let mealPrice = marker.mealPrice {
Text(mealPrice)
.font(Font(BMFont.regular(12)))
.foregroundColor(.primary)
} else {
Text("<10")
.font(Font(BMFont.regular(12)))
.foregroundColor(.primary)
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bring .font(Font(BMFont.regular(12))) and .foregroundColor(.primary) out and apply it to Group?

Comment on lines 154 to 194
private func getCategoryIcon() -> String {
guard let marker else {
return "questionmark.circle"
}

switch marker.type {
case .known(let type):
switch type {
case .cafe:
return "fork.knife"
case .store:
return "bag"
case .mentalHealth:
return "brain"
case .genderInclusiveRestrooms:
return "toilet"
case .menstrualProductDispensers:
return "drop"
case .garden:
return "leaf"
case .bikes:
return "bicycle"
case .lactation:
return "heart"
case .rest:
return "bed.double"
case .microwave:
return "bolt"
case .printer:
return "printer"
case .water:
return "drop.fill"
case .waste:
return "trash"
case .none:
return "mappin"
}
case .unknown:
return "mappin"
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we have a icon() method on a MapMarker that returns a UIImage? maybe use that?

@Chhumbucket Chhumbucket changed the title BER-80: Converting MapMarkerDetailView into SwiftUI BER-80: Converting MapMarkerDetailView into SwiftUI [WIP] May 25, 2025
@Chhumbucket Chhumbucket requested a review from baeuke May 30, 2025 22:27
@Chhumbucket
Copy link
Collaborator Author

Chhumbucket commented May 30, 2025

Let me know how you like the UI

Screen.Recording.2025-05-30.at.3.23.57.PM.mov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants